//
//  ExamineTableViewCell.m
//  gdemm
//
//  Created by 乔明超 on 16/11/1.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "ExamineTableViewCell.h"
#import "Masonry.h"
@interface ExamineTableViewCell()
@property(nonatomic,strong)UILabel * titleLabel;
@property(nonatomic,strong)UIImageView *stateImg;
@end
@implementation ExamineTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(skinSwitchHandler) name:@"skinswitch" object:nil];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.textColor = [Utils colorWithKey:@"evaluationTitleColor"];
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        self.titleLabel.numberOfLines = 0;
        [self addSubview:self.titleLabel];
        self.stateImg = [[UIImageView alloc]init];
        [self.stateImg sizeToFit];
        [self addSubview:self.stateImg];
    }
    return self;
}

- (void)setItem:(ItemModel *)item{
    _item = item;
    self.titleLabel.text = item.itemInfo;
    if (item.state == NO) {
        self.stateImg.image = [Utils getImageByDevce:@"ceping_icon_08"];
    }else{
        self.stateImg.image = [Utils getImageByDevce:@"ceping_icon_09"];
    }

}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

//    if (selected) {
//        self.backgroundColor = [Utils colorWithKey:@"mainBgColor"];
//    }
    // Configure the view for the selected state
}


-(void)layoutSubviews{
    if ([DeviceTypeJudge isPadDeviceType]) {
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).mas_offset(75);
            make.top.mas_equalTo(self).mas_offset(7);
        }];
        [self.stateImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLabel);
            make.right.mas_equalTo(self.mas_right).mas_offset(-30);
        }];
        self.titleLabel.font = [UIFont systemFontOfSize:16];
    }else{
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self).mas_offset(35);
            make.top.mas_equalTo(self).mas_offset(7);
            make.right.mas_equalTo(self).mas_offset(-35);
        }];
        [self.stateImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLabel);
            make.width.height.mas_equalTo(12);
            make.right.mas_equalTo(self.mas_right).mas_offset(-16);
        }];
        self.titleLabel.font = [UIFont systemFontOfSize:11];
    }
   
    
    [super layoutSubviews];
}
/**
 *  切换肤色
 */

- (void)skinSwitchHandler{
    self.titleLabel.textColor = [Utils colorWithKey:@"evaluationTitleColor"];
}
@end
